using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;

namespace Tools.UI
{
    [AddComponentMenu("Tools/UI/OnPointerExitEvent")]
    public class OnPointerExitEvent : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
    {
        [SerializeField] UnityEvent<PointerEventData> onPointerEnterEvent;
        [SerializeField] UnityEvent<PointerEventData> onPointerExitEvent;

        public UnityEvent<PointerEventData> PointerEnterEvent => onPointerEnterEvent;
        public UnityEvent<PointerEventData> PointerExitEvent => onPointerExitEvent;
        
        void IPointerEnterHandler.OnPointerEnter(PointerEventData eventData)
        {
            Debug.Log($"{name} OnPoint Enter");
            onPointerEnterEvent?.Invoke(eventData);
        }
        
        void IPointerExitHandler.OnPointerExit(PointerEventData eventData)
        {
            Debug.Log($"{name} OnPoint Exit");
            onPointerExitEvent?.Invoke(eventData);
        }
    }
}
